package org.dk.file;


import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class ReadFile {
    private ReadFile() {
    }

    public static String readFile(String path) {
        StringBuilder res = new StringBuilder();
        try {
            Scanner sc = new Scanner(new FileReader(path));
            while (sc.hasNextLine()) {  //按行读取字符串
                String line = sc.nextLine();
                res.append(line).append("\n");
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return res + "";
    }
}
